home *** CD-ROM | disk | FTP | other *** search
- Path: news.ox.ac.uk!news
- From: imc@ecs.ox.ac.uk (Ian Collier)
- Newsgroups: comp.lang.rexx
- Subject: Re: Object Rexx (was Re: How can I pass an array (stem) to a function?
- Date: 8 Jan 1996 18:06:05 GMT
- Organization: Oxford University Computing Laboratory
- Distribution: inet
- Message-ID: <7601.imc@comlab.ox.ac.uk>
- References: <7579.imc@comlab.ox.ac.uk> <4b6jdt$nmp@osiris.wu-wien.ac.at>
- NNTP-Posting-Host: boothp2.ecs.ox.ac.uk
- X-Local-Date: Monday, 8th January 1996 at 6:06pm GMT
-
- In article <4b6jdt$nmp@osiris.wu-wien.ac.at>, Rony.Flatscher@wu-wien.ac.at
- wrote:
- >>>>Does this mean that a combination such as
-
- >>>> call test 3+4
- >>>> test: use arg x
-
- >>>>would not generate an error? How can you pass an expression by reference?
-
- >>>Yes, it would *not* generate an error.
-
- >>Can you assign to the variable x, or is x in some way labelled as a constant
- >>because it is a reference to the value '7'?
-
- >Yup, assignment possible anytime. "x" is a true variable (as opposed to a
- >pseudo variable, which one cannot set).
-
- Surely this could lead to accidents. If for example I put the parameters
- in the wrong order then it would carry on as if nothing happened instead
- of saying "whoops, there should have been a variable here".
-
- In effect, if I type
-
- call test 7
- test: use arg x
- x=6
-
- I am asking for the value of '7' to be changed to 6. As I'm sure most people
- know, this actually happened on some versions of FORTRAN. But REXX will
- silently ignore me instead of detecting something wrong.
-
- >"USE ARG" essentially allows for defining functions/procedures/routines/methods
- >which need to operate directly on the passed in objects themselves (and not on
- >their string representation as ARG( n ) or "PARSE ARG").
-
- I imagine then that something like
-
- call test .array~new
- test: use arg x
-
- is possible. I can't think of a circumstance in which this would be
- useful, but I suppose there must be some uses for passing by reference
- something that isn't a variable. There is no need to do this with
- strings though, because they can be passed by value (and since I'm
- interested in applications of "use arg" to classic Rexx, strings are
- my main consideration).
-
- > (If a NOVALUE was raised at the "USE ARG" statement this
- >(extremely important) technique was impossible to employ, or with other words:
- >it would be impossible to write a function/procedure/routine/method such, that
- >it could work irrespectivle of supplied arguments !)
-
- You would simply have to check before doing the USE ARG instruction. For
- that I would replace the VAR function by ARG(n,'V'), so, to translate your
- example...
-
- :: Method Init
- use arg anObject
- if arg(2,"V") then use arg ,bCreate
- else bCreate = .true
- if bCreate then
- self ~ class ~ setup(anObject, self)
-
- Ian Collier - imc@comlab.ox.ac.uk - WWW Home Page (including REXX section):
- http://www.comlab.ox.ac.uk/oucl/users/ian.collier/index.html
-